package demo.hdz.testui;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * @author hdz
 * @date 2018/07/21
 */
public class JumpAnimActivity extends AppCompatActivity implements View.OnClickListener {

    TextView textView;

    private String jumpStyle = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jump_anim);

        Button btnBack = (Button) findViewById(R.id.btnBack);
        btnBack.setOnClickListener(this);

        textView = (TextView) findViewById(R.id.textView);

        jumpStyle = getIntent().getStringExtra("Style");
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (jumpStyle.equals("LeftInRightOut")) {
            textView.setText("左进右出");
        }
        Log.d("==", jumpStyle);
    }

    @Override
    public void onBackPressed() {
        back();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btnBack:
                back();
                break;
            default:
                break;
        }
    }

    private void back() {
        if (jumpStyle.equals("LeftInRightOut")) {
            finish();
            overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_from_right);
        }
    }


}
